<template>
	<view class="being">
		<view class="content">

			<view class="top" :style="{'padding-top': paddingTop}">
				<uni-icons @click="toBackPage" style="margin-left: 30rpx;width: 50rpx;" type="left" size="25"
					color="#2c2c2c">
				</uni-icons>
				<view style="display: flex;flex-direction: row;text-align:center;width: 150rpx;margin-left: 220rpx;">
					浪者空间</view>
			</view>

			<view class="search">
				<uni-icons type="search" size="25" color="#2c2c2c"></uni-icons>
				<input @blur="pageCourse" style="width:570rpx" placeholder="请输入名称或描述关键词" v-model="queryInput.name" />
			</view>
			
			<view class="wind-spaces" v-if="windSpacesList && windSpacesList.length>0">
				<view v-for="(space,index) in windSpacesList" @click="gotoSpaceManage(space.id,space.type)"
					class="wind-space">
					<view class="cover">
						<image mode="aspectFill" :src="space.cover"></img>
					</view>
					<view class="info">
						<view class="name">{{space.name}}</view>
						<view class="description">{{space.description}}</view>
					</view>
				</view>
			</view>
			
			<view class="wind-spaces-empty" v-else>
				<view class="text">暂时没有哦，去探索其他区域吧</view>
			</view>

		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				queryInput: {
					pageNow: 1,
					pageSize: 20,
					total: 0,
					name: ""
				},
				windSpacesList: [],
				paddingTop: null
			}
		},
		onLoad() {
			this.listWindSpace();
			
			// 调整搜索位置
			// #ifdef MP-WEIXIN
			// 1.获取屏幕可使用宽度
			let windowWidth = uni.getSystemInfoSync().windowWidth;
			// 3.获取胶囊按钮位置信息
			const menuButton = uni.getMenuButtonBoundingClientRect();
			// // 5.导航栏与状态栏拉开距离  margin-top: statusBarTop + 'rpx';
			this.paddingTop = menuButton.top * (750 / windowWidth) + 'rpx';
			// #endif
		},
		methods: {
			listWindSpace() {
				this.$api.listWindSpace().then(res => {
					this.windSpacesList = res.data
				})
			},
			gotoSpaceManage(id, type) {
				if (type === 3) {
					uni.navigateTo({
						url: '/pages_self/wind/manage/course/course-manage?courseId=' + id
					});
				}  else {
					uni.navigateTo({
						url: '/pages_self/wind/manage/island/island-manage?islandId=' + id
					});
				}
			
			},
			toBackPage(){
				uni.navigateBack()
			}
		}
	}
</script>

<style scoped lang="scss">
	.being {
		background-color: #FAFAFA;
		min-height: 100vh;

		.content {
			display: flex;
			flex-direction: column;

			.top {
				width: 100%;
				height: 50rpx;
				//#ifdef MP-WEIXIN
				width: 550rpx;
				//#endif

				padding-top: 100rpx;

				// #ifdef H5
				padding-top: 40rpx;
				// #endif

				padding-bottom: 20rpx;

				display: flex;
				flex-direction: row;
				align-items: center;
				box-shadow: 1px 1px 8px 2px #f0f0f0;
			}


			.search {
				height: 80rpx;
				width: 640rpx;
				margin: 30rpx 0 30rpx 30rpx;
				background-color: #FFFFFF;
				box-shadow: 1px 1px 8px 2px #f0f0f0;
				border-radius: 20rpx;

				padding: 0 20rpx;

				display: flex;
				flex-direction: row;
				justify-content: space-between;
				align-items: center;


			}

			.title {
				font-size: 36rpx;
				font-weight: bold;
				margin: 30rpx 0 30rpx 30rpx;
				position: relative;
				width: 690rpx;
				display: flex;
				flex-direction: row;
				justify-content: space-between;

				.mark {
					width: 45rpx;
					height: 35rpx;
					background-color: #B3DFDE;
					border-radius: 40%;
					position: absolute;

					top: 5rpx;
					left: 0;
					z-index: 1;
				}

				.text {
					padding-left: 15rpx;
					position: relative;
					z-index: 2;
					letter-spacing: 4rpx;
				}

				.right {
					display: flex;
					flex-direction: row;
					align-items: center;
					font-size: 28rpx;
					margin-bottom: 5rpx;
					font-weight: normal;
				}

			}
			
			.wind-spaces-empty{
				width: 670rpx;
				margin: 20rpx 0;
				margin-left: 40rpx;
				height: 250rpx;
				border-radius: 20rpx;
				
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				
				.text{
					letter-spacing: 5rpx;
				}
				
				
			}

			.wind-spaces {
			
				display: flex;
				flex-direction: column;
				width: 670rpx;
				margin-left: 40rpx;
			
			
				.wind-space {
					display: flex;
					flex-direction: row;
					justify-content: space-between;
			
					margin-bottom: 30rpx;
					border-radius: 20rpx;
					padding: 30rpx;
					width: 610rpx;
			
					background-color: #FFFFFF;
			
					.cover {
						width: 240rpx;
						height: 170rpx;
						border-radius: 10rpx;
						overflow: hidden;
					}
			
					.info {
						width: 350rpx;
						height: 160rpx;
						margin-top: 5rpx;
						display: flex;
						flex-direction: column;
						justify-content: space-between;
			
						.name {
							font-size: 36rpx;
							font-weight: 500;
						}
			
						.description {
							margin-top: 10rpx;
							font-size: 28rpx;
							color: gray;
			
							/*超过范围进行隐藏不显示*/
							overflow: hidden;
							/*文本溢出, 使用省略号 */
							text-overflow: ellipsis;
							/* 以webkit盒子展示, 比较适用于webkit内核和移动端*/
							display: -webkit-box;
							/*限制块容器显示的文本行数, 按照你的需求设置*/
							-webkit-line-clamp: 2;
							/*盒子的方向, 垂直、水平等*/
							-webkit-box-orient: vertical;
							/*文字换行, 可以在单词内断*/
							word-wrap: break-word;
						}
					}
			
					.question-info {
						width: 610rpx;
						margin-top: 5rpx;
						display: flex;
						flex-direction: column;
						justify-content: space-between;
			
						.name {
							font-size: 36rpx;
							font-weight: 500;
						}
			
						.description {
							margin-top: 10rpx;
							font-size: 28rpx;
							color: gray;
			
							/*超过范围进行隐藏不显示*/
							overflow: hidden;
							/*文本溢出, 使用省略号 */
							text-overflow: ellipsis;
							/* 以webkit盒子展示, 比较适用于webkit内核和移动端*/
							display: -webkit-box;
							/*限制块容器显示的文本行数, 按照你的需求设置*/
							-webkit-line-clamp: 2;
							/*盒子的方向, 垂直、水平等*/
							-webkit-box-orient: vertical;
							/*文字换行, 可以在单词内断*/
							word-wrap: break-word;
						}
					}
				}
			}
		}

	}


	image {
		width: 100%;
		height: 100%;
	}

	img {
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
</style>
